<?php
class PersistanceEntrepot extends Entrepot{
	
	public function __construct($siteId){
		parent::__construct($siteId);
	}
	
	public function getEtatStock(){
		
		$sql = "SELECT Count(*) as stock, TA.nomType, TA.modele
				FROM Entrepot E, Article A, TypeArticle TA
				WHERE E.idSite = '".$this->getId()."'
				AND A.typeArticle = TA.idType
				AND E.idSite = A.entrepot";
		
		$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
		
		$tab = array();
		$i = 0;
		
		while($row=mysql_fetch_array($req)){
			$tab[$i]= $row;
			$i++;
		}
		
		return  $tab ;
	}
	
	public static function getAll(){
		$sql = "SELECT *
				FROM Entrepot";
		
		$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
		
		$tab = array();
		$i = 0;
		
		while($row=mysql_fetch_array($req)){
			$tab[$i]= $row;
			$i++;
		}
		
		return  $tab ;
	}
}

?>